package com.personal.website.lottery.web.service.impl;

import com.personal.website.lottery.web.common.PageType;
import com.personal.website.lottery.web.dao.PageMapper;
import com.personal.website.lottery.web.model.Page;
import com.personal.website.lottery.web.model.PageExample;
import com.personal.website.lottery.web.service.PageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by 10171225 on 2016/6/22.
 */
@Service("pageService")
public class PageServiceImpl implements PageService {
    @Resource
    private PageMapper pageMapper;

    public Page getPage(String type) {
        PageExample example = new PageExample();
        example.createCriteria().andPageTypeEqualTo(type);
        example.setLimitLength(1);
        return this.pageMapper.selectByExample(example).get(0);
    }

    public boolean updatePage(Page page) {
        return this.pageMapper.updateByPrimaryKey(page) == 1;
    }
}
